package loadfeaturefiles;

use GDBM_File;

use Vaanee qw(%dbs %C);

@ISA = qw(Exporter);
@EXPORT = qw();
@EXPORT_OK =  qw(%dbs %C);

#require "vaanee.config";

$DATABASE = $ENV{'DATABASE'};

sub load_featurefiles {

		print STDERR $DATABASE.": Database path\n";

		# Decoding Tables
                dbmopen(%{$dbs{'TreeletRootSrc'}},"$DATABASE/TreeletRootSrc.db",0666) || die "Can't open TreeletRootSrc";
                dbmopen(%{$dbs{'cacheTreeletRootSrc'}},"$DATABASE/cacheTreeletRootSrc.db",0666) || die "Can't open cacheTreeletRootSrc";

                dbmopen(%{$dbs{'Role2VibSrc'}},"$DATABASE/Role2VibSrc.db",0666) || die "Can't open Role2VibSrc";
                dbmopen(%{$dbs{'cacheRole2VibSrc'}},"$DATABASE/cacheRole2VibSrc.db",0666) || die "Can't open cacheRole2VibSrc";

                dbmopen(%{$dbs{'Tense2TenseSrc'}},"$DATABASE/Tense2TenseSrc.db",0666) || die "Can't open Tense2Tense";
                dbmopen(%{$dbs{'cacheTense2TenseSrc'}},"$DATABASE/cacheTense2TenseSrc.db",0666) || die "Can't open cacheTense2Tense";

                dbmopen(%{$dbs{'Gnp2GnpSrc'}},"$DATABASE/Gnp2GnpSrc.db",0666) || die "Can't open Gnp2Gnp";
                dbmopen(%{$dbs{'cacheGnp2GnpSrc'}},"$DATABASE/cacheGnp2GnpSrc.db",0666) || die "Can't open cacheGnp2Gnp";

                dbmopen(%{$dbs{'ReorderRulesSrc'}},"$DATABASE/ReorderRulesSrc.db",0666) || die "Can't open Gnp2Gnp";
                dbmopen(%{$dbs{'cacheReorderRulesSrc'}},"$DATABASE/cacheReorderRulesSrc.db",0666) || die "Can't open cacheGnp2Gnp";


		# Feature Databases
                dbmopen(%{$dbs{'Atomictreelet'}},"$DATABASE/treeletRoot.prob.db",0666) || die "Can't open atomic_treelet.....db";
                dbmopen(%{$dbs{'cacheAtomictreelet'}},"$DATABASE/cache_treelet.prob.db",0666) || die "Can't open cache atomic_treelet";

                dbmopen(%{$dbs{'gnpProb'}},"$DATABASE/gnp.prob.db",0666) || die "Can't open gnp.prob.db.....db";
                dbmopen(%{$dbs{'cachegnpProb'}},"$DATABASE/cache_gnp.prob.db",0666) || die "Can't open cache_gnp.prob.db.....db";
                
		dbmopen(%{$dbs{'tenseProb'}},"$DATABASE/tense.prob.db",0666) || die "Can't open tense.prob.db.....db";
                dbmopen(%{$dbs{'cachetenseProb'}},"$DATABASE/cache_tense.prob.db",0666) || die "Can't open cache_tense.prob.db.....db";
		
		dbmopen(%{$dbs{'vibProb'}},"$DATABASE/vib.prob.db",0666) || die "Can't open vib.prob.db.....db";
                dbmopen(%{$dbs{'cachevibProb'}},"$DATABASE/cache_vib.prob.db",0666) || die "Can't open cache_vib.prob.db.....db";

		dbmopen(%{$dbs{'reorderRulesProb'}},"$DATABASE/reorderRules.prob.db",0666) || die "Can't open reorderRules.prob.db.....db";
                dbmopen(%{$dbs{'cachereorderRulesProb'}},"$DATABASE/cache_reorderRules.prob.db",0666) || die "Can't open cache_reorderRules.prob.db.....db";

		dbmopen(%{$dbs{'diceRootProb'}},"$DATABASE/diceRoot.prob.db",0666) || die "Can't open vib.prob.db.....db";
                dbmopen(%{$dbs{'cachediceRootProb'}},"$DATABASE/cache_diceRoot.prob.db",0666) || die "Can't open cache_vib.prob.db.....db";


                dbmopen(%{$dbs{'cacheWordSubTree'}},"$DATABASE/cache_wordSubTree.db",0666) || die "Can't open cache_wordSubTree.db";

#		dbmopen(%{$dbs{'VaaneeDict'}},"$DATABASE/VaaneeDict.db",0666) || die "Can't open VaaneeDict.db";
#	
#		dbmopen(%{$dbs{'VaaneeDict'}},"$DATABASE/VaaneeDict.db",0666) || die "Can't open VaaneeDict.db";
#		dbmopen(%{$dbs{'VaaneeSyndiv'}},"$DATABASE/VaaneeSyndiv.db",0666) || die "Can't open VaaneeSyndiv.db";
#
#                dbmopen(%{$dbs{'cacheDicewd'}},"$DATABASE/cacheDiceWord.db",0666) || die "Can't open cacheDicewd.db";
#                dbmopen(%{$dbs{'cacheDicert'}},"$DATABASE/cacheDiceRoot.db",0666) || die "Can't open cacheDiceRoot.db";
#                dbmopen(%{$dbs{'cacheDicewdnull'}},"$DATABASE/cacheDiceWord.Null.db",0666) || die "Can't open cacheDicewd.null.db";
#                dbmopen(%{$dbs{'cacheDicertnull'}},"$DATABASE/cacheDiceRoot.Null.db",0666) || die "Can't open cacheDiceRoot.null.db";
#		# dbmopen(%{$dbs{'cacheDict'}},"$DATABASE/cacheDict.db",0666)       || die "Can't open cacheDict.db";
#
#                dbmopen(%{$dbs{'cacheBasicEngHnd'}},"$DATABASE/GIZA/cacheBasicEngHnd.db",0666) || die "Can't open cacheBasicEngHnd.db";
#                dbmopen(%{$dbs{'cacheBasicHndEng'}},"$DATABASE/GIZA/cacheBasicHndEng.db",0666) || die "Can't open cacheBasicHndEng.db";
#                dbmopen(%{$dbs{'cacheRootEngHnd'}},"$DATABASE/GIZA/cacheRootEngHnd.db",0666)   || die "Can't open cacheRootEngHnd.db";
#                dbmopen(%{$dbs{'cacheRootHndEng'}},"$DATABASE/GIZA/cacheRootHndEng.db",0666)   || die "Can't open cacheRootHndEng.db";
#		#dbmopen(%{$dbs{'cacheBasicEngHndPred'}},"$DATABASE/GIZA/cacheBasicEngHndPred.db",0666) || die "Can't open cacheBasicEngHnd.db";
#		#dbmopen(%{$dbs{'cacheBasicHndEngPred'}},"$DATABASE/GIZA/cacheBasicHndEngPred.db",0666) || die "Can't open cacheBasicHndEng.db";
#		#dbmopen(%{$dbs{'cacheRootEngHndPred'}},"$DATABASE/GIZA/cacheRootEngHndPred.db",0666)   || die "Can't open cacheRootEngHnd.db";
#		#dbmopen(%{$dbs{'cacheRootHndEngPred'}},"$DATABASE/GIZA/cacheRootHndEngPred.db",0666)   || die "Can't open cacheRootHndEng.db";
#
#
#		dbmopen(%{$dbs{'cacheMI'}},"$DATABASE/cacheMI.db",0666) || die "Can't open cacheMI.db";
#
#		dbmopen(%{$dbs{'Dicewd'}},"$DATABASE/DiceWord.db",0666) ||die "Can't open DiceWord.db";
#		dbmopen(%{$dbs{'Dicert'}},"$DATABASE/DiceRoot.db",0666) ||die "Can't open $DATABASE/DiceRoot.db";
#		dbmopen(%{$dbs{'Dicewdnull'}},"$DATABASE/DiceWordNull.db",0666) ||die "Can't open DiceWord.null.db";
#		dbmopen(%{$dbs{'Dicertnull'}},"$DATABASE/DiceRootNull.db",0666) ||die "Can't open DiceRoot.null.db";
#	   	dbmopen(%{$dbs{'Dict'}},"$DATABASE/newDict.db",0666)               || die "Can't open newDict.db";
#
#		dbmopen(%{$dbs{'BasicEngHnd'}},"$DATABASE/basic_eng_hnd_giza.db",0666) 
#										|| die "Can't open basic_eng_hnd_giza.db";
#		dbmopen(%{$dbs{'BasicHndEng'}},"$DATABASE/basic_hnd_eng_giza.db",0666) 
#										|| die "Can't open basic_eng_hnd_giza.db";
#		dbmopen(%{$dbs{'RootEngHnd'}},"$DATABASE/root_eng_hnd_giza.db",0666) 
#										|| die "Can't open root_eng_hnd_giza.db";
#		dbmopen(%{$dbs{'RootHndEng'}},"$DATABASE/root_hnd_eng_giza.db",0666) 
#										|| die "Can't open Basic Eng Hnd";
		#dbmopen(%{$dbs{'BasicEngHndPred'}},"$DATABASE/basic_eng_hnd_giza_pred.db",0666) 
		#								|| die "Can't open basic_eng_hnd_giza.db";
		#dbmopen(%{$dbs{'BasicHndEngPred'}},"$DATABASE/basic_hnd_eng_giza_pred.db",0666) 
		#								|| die "Can't open basic_eng_hnd_giza.db";
		#dbmopen(%{$dbs{'RootEngHndPred'}},"$DATABASE/root_eng_hnd_giza_pred.db",0666) 
		#								|| die "Can't open root_eng_hnd_giza.db";
		#dbmopen(%{$dbs{'RootHndEngPred'}},"$DATABASE/root_hnd_eng_giza_pred.db",0666) 
		#	|| die "Can't open Basic Eng Hnd";

		#dbmopen(%{$dbs{'MI'}},"$DATABASE/MI.new.db",0666) || die "Can't open MI.new.db";

}

sub unload_featurefiles {


		dbmclose(%{$dbs{'TreeletRootSrc'}});
                dbmclose(%{$dbs{'cacheTreeletRootSrc'}});

                dbmclose(%{$dbs{'Role2VibSrc'}});
                dbmclose(%{$dbs{'cacheRole2VibSrc'}});

                dbmclose(%{$dbs{'Tense2TenseSrc'}});
                dbmclose(%{$dbs{'cacheTense2TenseSrc'}});

                dbmclose(%{$dbs{'Gnp2GnpSrc'}});
                dbmclose(%{$dbs{'cacheGnp2GnpSrc'}});


                dbmclose(%{$dbs{'Atomictreelet'}});
                dbmclose(%{$dbs{'cacheAtomictreelet'}});
                
		dbmclose(%{$dbs{'gnpProb'}});
                dbmclose(%{$dbs{'cachegnpProb'}});
                
		dbmclose(%{$dbs{'tenseProb'}});
                dbmclose(%{$dbs{'cachetenseProb'}});
		
		dbmclose(%{$dbs{'vibProb'}});
                dbmclose(%{$dbs{'cachevibProb'}});
		
		dbmclose(%{$dbs{'diceRootProb'}});
                dbmclose(%{$dbs{'cachediceRootProb'}});

#                dbmclose(%{$dbs{'VaaneeDict'}});
#                dbmclose(%{$dbs{'VaaneeSyndiv'}});
#
#                dbmclose(%{$dbs{'cacheDicewd'}});
#                dbmclose(%{$dbs{'cacheDicert'}});
#                dbmclose(%{$dbs{'cacheDicewdnull'}});
#                dbmclose(%{$dbs{'cacheDicertnull'}});
#                dbmclose(%{$dbs{'cacheDict'}});
#
#                dbmclose(%{$dbs{'cacheBasicEngHnd'}});
#                dbmclose(%{$dbs{'cacheBasicHndEng'}});
#                dbmclose(%{$dbs{'cacheRootEngHnd'}});
#                dbmclose(%{$dbs{'cacheRootHndEng'}});
#
#                dbmclose(%{$dbs{'cacheMI'}});
#
#                dbmclose(%{$dbs{'Dicewd'}});
#                dbmclose(%{$dbs{'Dicert'}});
#                dbmclose(%{$dbs{'Dict'}});
#
#                dbmclose(%{$dbs{'BasicEngHnd'}});
#                dbmclose(%{$dbs{'BasicHndEng'}});
#                dbmclose(%{$dbs{'RootEngHnd'}});
#                dbmclose(%{$dbs{'RootHndEng'}});
#
#                dbmclose(%{$dbs{'MI'}});
}

1;
